//
//  UDPSorket.h
//  UDPSocket
//
//  Created by Andy JMR on 16/3/31.
//  Copyright © 2016年 JMR. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <GCDAsyncUdpSocket.h>
#import "BroadcastPack.h"

@class YSUDPSocket ;
@protocol YSUDPSocketDalegate <NSObject>


//-(void)udpSocket:(GCDAsyncUdpSocket *)sock didConnectToAddress:(NSData *)address;
//
//-(void)udpSocket:(UDPSocket *)sock didNotConnect:(NSError *)error;

//-(void)udpSocket:(UDPSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError *)error;

-(void)udpSocket:(YSUDPSocket *)sock didReceiveData:(BroadcastPack *)pack fromAddress:(NSData *)address withFilterContext:(id)filterContext;

//-(void)udpSocket:(UDPSocket *)sock didSendDataWithTag:(long)tag;
//-(void)udpSocketDidClose:(GCDAsyncUdpSocket *)sock withError:(NSError *)error;
@end
@interface YSUDPSocket : NSObject

- (void)setupUDPSocketBindingPort:(uint16_t)port;
- (void)sendData;
- (void)sendData:(NSData *)data
          toHost:(NSString *)host
            port:(uint16_t)port
     withTimeout:(NSTimeInterval)timeout
             tag:(long)tag;
@property(nonatomic, weak)id<YSUDPSocketDalegate>delegate;
- (void) disabled;
@end
